home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cenvid9.zip / TEE.CMM < prev    next >
Text File  |  1994-03-04  |  992b  |  34 lines

  1. //******************************************
  2. //*** Tee.cmm - Send lines to screen and ***
  3. //*** ver.1     to output file           ***
  4. //******************************************
  5.  
  6. main(argc,argv)
  7. {
  8.    if ( 2 != argc )
  9.       Instructions();
  10.    else {
  11.       // open ouput file
  12.       if ( NULL == (fp=fopen(argv[1],"w")) )
  13.          printf("Could not open file \"%s\" for writing.\a\n",argv[1])
  14.       else {
  15.          // read in each line, and send to file and screen
  16.          while ( NULL != (line=gets()) ) {
  17.             printf("%s\n",line)
  18.             fprintf(fp,"%s\n",line)
  19.          }
  20.          fclose(fp)
  21.       }
  22.    }
  23. }
  24.  
  25.  
  26. Instructions()
  27. {
  28.    printf("Tee.cmm - Pipe output to screen AND to a file\n");
  29.    printf("USAGE: Tee.cmm <FileSpec>\n");
  30.    printf("  Where:  FileSpec = Name of file to create and write text to\n");
  31.    printf("Example: To see output of a dir listing, but also save it in a file:\n");
  32.    printf("     dir | cenvi tee.cmm dir.txt\n");
  33. }
  34.